package com.company.cloud.pay.modules.pay.utils;

import com.company.cloud.common.exception.BusinessException;
import com.company.cloud.pay.modules.api.constant.PayTradeType;

import java.util.HashMap;
import java.util.Map;

public class PayTradeTypeUtil {

    public static Map<String, PayTradeType> getPayTradeTypeMap() {
        Map<String, PayTradeType> map = new HashMap<String, PayTradeType>();
        for (final PayTradeType e : PayTradeType.class.getEnumConstants()) {
            map.put(e.getCode(), e);
        }
        return map;
    }

    public static PayTradeType getPayTradeTypeByCode(String code) {
        for (final PayTradeType e : PayTradeType.class.getEnumConstants()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        throw new BusinessException("不支持的支付方式:" + code);
    }

}
